import 'package:ati_package/core/extension/ati_widgets_extension.dart';
import 'package:ati_package/core/routes/app_routes.dart';
import 'package:ati_package/core/utils/ati_color.dart';
import 'package:ati_package/core/utils/ati_font.dart';
import 'package:ati_package/pages/common/ati_scaffold.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get_core/get_core.dart';
import 'package:get/get_navigation/get_navigation.dart';

import '../../../../core/utils/ati_assets.dart';
import '../../../common/widgets/ati_common_btn.dart';

class WalletAddressView extends StatefulWidget {
  const WalletAddressView({super.key});

  @override
  State<WalletAddressView> createState() => _WalletAddressViewState();
}

class _WalletAddressViewState extends State<WalletAddressView> {
  @override
  Widget build(BuildContext context) {
    return AtiScaffold(
      title: '钱包地址',
      body: Container(
        margin: EdgeInsets.only(top: 16.r),
        child: Column(
          children: [
            _buildWalletAddressListWidget(),
            _buildNoWalletAddressWidget(),
            _buildTapAndfootBtn(),
          ],
        ),
      ),
    );
  }

  _buildNoWalletAddressWidget() {
    return Container(
      height: 50.r,
      margin: EdgeInsets.only(left: 16, right: 16.r, bottom: 16.r),
      width: double.infinity,
      padding: EdgeInsets.only(left: 16.r),
      alignment: Alignment.centerLeft,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8.r),
      ),
      child: Text('+添加钱包地址'),
    ).addTapGesture(
      onTap: () {
        Get.toNamed(AtiAppRoutes.userAddWalletAddress);
      },
    );
  }

  _buildWalletAddressListWidget() {
    return Container(
      margin: EdgeInsets.only(left: 16.r, right: 16.r),
      child: ListView.builder(
        padding: EdgeInsets.zero,
        shrinkWrap: true,
        itemCount: 3,
        itemBuilder: (context, index) {
          return buildItem();
        },
      ),
    );
  }

  buildItem() {
    return Container(
      padding: EdgeInsets.only(
        top: 16.r,
        bottom: 12.r,
        left: 16.r,
        right: 16.r,
      ),
      margin: EdgeInsets.only(bottom: 12.r),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8.r),
      ),

      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              Text(
                'USDT-TRC20',
                style: TextStyle(
                  fontSize: AtiFont.font14,
                  color: AtiColor.textColor1,
                  fontWeight: FontWeight.w600,
                ),
              ),
              Spacer(),
              Image.asset(
                width: 22.5.r,
                AtiAssets.atiCopyIcon,
                package: 'ati_package',
              ),
            ],
          ),
          SizedBox(height: 10.r),
          Row(
            children: [
              Text(
                'T9z2kvNgUNTxBdvFsqecMUwoJkriGEN5Fh',
                style: TextStyle(
                  fontSize: AtiFont.font12,
                  color: Color(0xFF666666),
                ),
              ),
              Spacer(),
            ],
          ),
        ],
      ),
    );
  }

  _buildTapAndfootBtn() {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 30.r),

      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '温馨提示',
            style: TextStyle(
              color: Color(0xFF666666),
              fontSize: AtiFont.font12,
            ),
          ),
          SizedBox(height: 2.5.r),
          Text(
            '1、USDT地址只可添加一个\n2、修改地址请联系在线客服',
            style: TextStyle(
              color: Color(0xFF666666),
              fontSize: AtiFont.font12,
            ),
          ),

          AtiCommonBtn(
            onPressed: () {},
            titleStr: '在线客服',
            margin: EdgeInsets.symmetric(horizontal: 10.r, vertical: 32.r),
          ),
        ],
      ),
    );
  }
}
